package edu.usc.libtalk;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.TabActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TabHost;

public class SignInWithLocActivity extends TabActivity {
	public final static String SIGNIN_WL_EXTRA_MODE = "edu.usc.libtalk.signinwithlocactivity.mode";
	public static Activity signInWithLocActivity;
	
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        // Customize menu title 
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        
        setContentView(R.layout.activity_sign_in_with_loc);
        
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
        
        // Help button Handler    	
    	Button help_bn = (Button) findViewById(R.id.help_button);
    	help_bn.setOnClickListener(new OnClickListener() {
    		public void onClick(View v) {
    			helpDialog();
    		}
    	});    	
        
        signInWithLocActivity = this;
        
        Resources res = getResources(); // Resource object to get Drawables
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabHost.TabSpec spec;  // Reusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab   
                
        // Initialize a TabSpec for each tab and add it to the TabHost
        // SSL Level 1 tab
        intent = new Intent().setClass(SignInWithLocActivity.this, SSL1Activity.class); 
        intent.putExtra(SIGNIN_WL_EXTRA_MODE, "SIGNIN_MODE");
        spec = tabHost.newTabSpec("ssl1").setIndicator("Level 1",
                          res.getDrawable(R.drawable.ic_library_level))
                      .setContent(intent);
        tabHost.addTab(spec);

        // SSL Level 2 tab
        intent = new Intent().setClass(SignInWithLocActivity.this, SSL2Activity.class);
        intent.putExtra(SIGNIN_WL_EXTRA_MODE, "SIGNIN_MODE");
        spec = tabHost.newTabSpec("ssl2").setIndicator("Level 2",
                          res.getDrawable(R.drawable.ic_library_level))
                      .setContent(intent);
        tabHost.addTab(spec);
 
        // SSL Level 3 tab
        intent = new Intent().setClass(SignInWithLocActivity.this, SSL3Activity.class);
        intent.putExtra(SIGNIN_WL_EXTRA_MODE, "SIGNIN_MODE");
        spec = tabHost.newTabSpec("ssl3").setIndicator("Level 3",
                          res.getDrawable(R.drawable.ic_library_level))
                      .setContent(intent);
        tabHost.addTab(spec);        
        
        tabHost.setCurrentTab(0);                
        
    }
    
    private void helpDialog()
    {
    	AlertDialog alertDialog = new AlertDialog.Builder(SignInWithLocActivity.this).create();
		
		// Setting Dialog Title
		alertDialog.setTitle("Help");
		
		// Setting Dialog Message
		alertDialog.setMessage("Step 1 : Select the Library.\n\nStep 2 : Login as Registered (with Name and Interest) or Anonymous User.\n\nStep 3 : If you are Registered user, then select your seat (free spot) on any level of that selected library.\n\nStep 4 : Click on the \"online users\" tab to see all the online users of that particular library with their \"Area of Interest\". Click any one from the list and start chat.\n\nStep 5 : You can also go to all the levels and can select users and start chat.\n\nStep 6 : After you are done chatting, click on the \"Sign out\" button on the header. Here you can also send the entire chat of your message board to your email.\n\nStep 7 : Happy Chatting ...");

		// Setting OK Button
		alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
		    public void onClick(DialogInterface dialog, int which) {
		    	// Write your code here to execute after dialog closed
		    		
		    }
		});
		
		alertDialog.show();
    }      

}
